<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$return['ischecklogin']=$this->model('member')->checklogin('','','','',true);
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	set_html('title',$this->setting['jie_title']?:'邀请任务');
	$return['pluginset']['goods_opentime']=date('Y-m-d',$return['pluginset']['goods_opentime']);
	$return['isyaonum']=pdo_count('core_members',array('createtime >'=>$return['pluginset']['goods_opentime'],'uniacid'=>$_SESSION['uniacid'],'fromuser'=>$_SESSION['uid']));
	$return['isyaoget']=$this->count('order',array('uniacid'=>$_SESSION['uniacid'],'agentid'=>$_SESSION['uid'],'isnew'=>1));
	if($return['pluginset']['jie_levels']){
		if($_SESSION['uid']){
			$levelid = pdo_getcolumn('jy_weishop_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'merchid'=>0),'level');
			if(strpos($return['pluginset']['jie_levels'],';'.$levelid.';') === false){
				$return['nocan']=1;
			}
		}else{
				$return['nocan']=1;
		}
	}
	if(intval($this->setting['jie_tpl2'])){
		$return['htmls']=$this->template_url('yao2');
	}
	$return['myurl']=custom_url('jy_newczfee/activity//fromuser='.$_SESSION['uid'],true);
	$nowplugin=$_SESSION['current_plugin']?:'jy_newczfee';
	$menus_index=$_SESSION['menus_index']?:$nowplugin.'/index/';
	$return['indexaction']=$menus_index;
	$return['homeaction']='jy_newczfee/index/';
	$sharelink='jy_newczfee/activity//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
		'title'=>$return['pluginset']['share_title']?$return['pluginset']['share_title']:'活动页-新人体验区',
		'desc'=>$return['pluginset']['share_desc']?$return['pluginset']['share_desc']:'新人体验区！',
		'link'=>custom_url($sharelink,true),
		'imgUrl'=>tomedia($return['pluginset']['share_image'])
	);
	exi($return);
}
if($_RQ['op']=='getlist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$goods_opentime=$this->setting['goods_opentime']?:0;
	$params=array('uniacid'=>$_SESSION['uniacid'],'fromuser'=>$_SESSION['uid']);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('core_members',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$item){
		$item['nickname'].='(ID:'.$item['id'].')';
		$item['avatar']=tomedia($item['avatar']);
		$feelog=$this->get('feelog',array('createtime >'=>$goods_opentime,'uniacid'=>$_SESSION['uniacid'],'type'=>1,'jie_mid'=>0,'mid'=>$item['id']));
		if($feelog['id']){
			$item['yaotitle']=$isfeelog['status']?'已参与新人体验':'新人体验订单已完成';
		}else{
			$item['yaotitle']='未参与新人体验';
		}
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
	}
	exi($return);
}